package com.wustl.android.hood;

import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;

public class HoodItemMainActions extends GridView {

	ActionsAdapter mAdapter;
	public Long itemLocationId;
	public HoodItemMainActions(Context context, AttributeSet attrs,
			Map inflateParams) {
		super(context, attrs, inflateParams);
		// TODO Auto-generated constructor stub
		
		mAdapter = new ActionsAdapter(context);
		this.setAdapter( mAdapter );
		

		this.setOnItemClickListener( new AdapterView.OnItemClickListener() {
		 	public void   onItemClick(AdapterView parent, View v, int position, long id) {
		 		onClick(v, position, id);
		 	}
		} );
	}
	
	protected void onClick(View v, int position, long id) {
		Intent i = new Intent(mContext, mAdapter.mThumbClass[position]);
		i.putExtra("mapLocationId", itemLocationId);
		((Activity) mContext).startSubActivity(i, 1);
	}
	
	public class ActionsAdapter extends BaseAdapter {
		
		public final Integer[] mThumbIds = {
				R.drawable.facebook,
				R.drawable.images,
				R.drawable.twitter,
		};
		public final Class[] mThumbClass = {
				FaceBookMain.class,
				FaceBookMain.class,
				TwitterMain.class,
		};
		
		public ActionsAdapter(Context c) {
			mContext = c;
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ImageView i = new ImageView(mContext);

            i.setImageResource(mThumbIds[position]);
            i.setLayoutParams(new Gallery.LayoutParams(50, 50));
            //i.setAdjustViewBounds(false);
            i.setScaleType(ImageView.ScaleType.FIT_CENTER);
            //i.setPadding(8, 8, 8, 8);

            return i;
		}

		public int getCount() { return mThumbIds.length; }
		public Object getItem(int position) { return position; }
		public long getItemId(int position) { return position; }
 
		
		private Context mContext;
	}
}
